package br.biofoco.p2p.services;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;

//import br.biofoco.p2p.scheduling.task.Task;
import br.biofoco.p2p.services.ServiceResult;

public final class TaskExecutor {
//
//	private final BlockingQueue<Task> queue = new LinkedBlockingQueue<Task>();
//	private ExecutorService executor = Executors.newSingleThreadExecutor();
//	private volatile boolean running = false;
//
//	public synchronized void start() {
//			while (running) {
//				try {
//					
//					Task task = queue.take();
//					Future<ServiceResult<?>> future = executor.submit(new ExecutableTask(task));
//					
//				} catch (InterruptedException e) {
//					e.printStackTrace();
//					running = false;
//				}
//				
//			}			
//	}
//
//	public synchronized void stop() {
//		running = false;
//		executor.shutdownNow();
//	}
//
//	public void enqueue(Task task) {
//		queue.add(task);
//	}
//
//	private class ExecutableTask implements Callable<ServiceResult<?>> {
//
//		private final Task task;
//
//		public ExecutableTask(Task task) {
//			this.task = task;
//		}
//
//		@Override
//		public ServiceResult<?> call() throws Exception {			
//			Process process = Runtime.getRuntime().exec(task.getCommand());			
//			return null;
//		}
//
//	}
}
